/**
  ******************************************************************************
  * @file    x_nucleo_iks01a1.h
  * @author  MEMS Application Team
  * @version V2.1.0
  * @date    4-April-2016
  * @brief   This file contains definitions for the x_nucleo_iks01a1.c
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  *
  * Redistribution and use in source and binary forms, with or without modification,
  * are permitted provided that the following conditions are met:
  *   1. Redistributions of source code must retain the above copyright notice,
  *      this list of conditions and the following disclaimer.
  *   2. Redistributions in binary form must reproduce the above copyright notice,
  *      this list of conditions and the following disclaimer in the documentation
  *      and/or other materials provided with the distribution.
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
  *      may be used to endorse or promote products derived from this software
  *      without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __X_NUCLEO_IKS01A1_H
#define __X_NUCLEO_IKS01A1_H

#ifdef __cplusplus
extern "C" {
#endif

 /* Includes ------------------------------------------------------------------*/
#include "stm32l0xx_hal.h"
#include "component.h"
//#include "accelerometer.h"
//#include "humidity.h"
//#include "temperature.h"

/** @addtogroup BSP BSP
 * @{
 */
//#define NUCLEO_I2C_EXPBD_TIMING_100KHZ       0x10A13E56 /* Analog Filter ON, Rise Time 400ns, Fall Time 100ns */
//#define NUCLEO_I2C_EXPBD_TIMING_400KHZ       0x0020040A /* Analog Filter ON, Rise Time 250ns, Fall Time 100ns */
 
#define NUCLEO_I2C_EXPBD_TIMING_100KHZ       0x10A13E56 /* Analog Filter ON, Rise Time 400ns, Fall Time 100ns */
#define NUCLEO_I2C_EXPBD_TIMING_400KHZ       0x00B1112E /* Analog Filter ON, Rise Time 250ns, Fall Time 100ns */
 
/* I2C peripheral configuration defines */
#define NUCLEO_I2C_EXPBD                            I2C1
#define NUCLEO_I2C_EXPBD_CLK_ENABLE()               __I2C1_CLK_ENABLE()
#define DMAx_CLK_ENABLE()                           __HAL_RCC_DMA1_CLK_ENABLE()
#define NUCLEO_I2C_EXPBD_SCL_SDA_GPIO_CLK_ENABLE()  __GPIOB_CLK_ENABLE()
#define NUCLEO_I2C_EXPBD_SCL_SDA_AF                 GPIO_AF1_I2C1
#define NUCLEO_I2C_EXPBD_SCL_SDA_GPIO_PORT          GPIOB
#define NUCLEO_I2C_EXPBD_SCL_PIN                    GPIO_PIN_6
#define NUCLEO_I2C_EXPBD_SDA_PIN                    GPIO_PIN_7

#define NUCLEO_I2C_EXPBD_FORCE_RESET()              __I2C1_FORCE_RESET()
#define NUCLEO_I2C_EXPBD_RELEASE_RESET()            __I2C1_RELEASE_RESET()

#define NUCLEO_I2C_EXPBD_EV_IRQn                    I2C1_IRQn

#define I2Cx_RX_DMA_CHANNEL             DMA_CHANNEL_1
#define I2Cx_RX_DMA_STREAM              DMA1_Stream5

/* Definition for I2Cx's NVIC */
#define I2Cx_DMA_IRQn                DMA1_Channel2_3_IRQn
#define I2Cx_DMA_IRQHandler          DMA1_Channel2_3_IRQHandler

/* Maximum Timeout values for flags waiting loops. These timeouts are not based
   on accurate values, they just guarantee that the application will not remain
   stuck if the I2C communication is corrupted.
   You may modify these timeout values depending on CPU frequency and application
   conditions (interrupts routines ...). */
#define NUCLEO_I2C_EXPBD_TIMEOUT_MAX    0x1000 /*<! The value of the maximal timeout for BUS waiting loops */

/* Definition for interrupt Pins */
#define LIS2DH12_INT1_GPIO_PORT                  GPIOA
#define LIS2DH12_INT1_GPIO_CLK_ENABLE()          __GPIOA_CLK_ENABLE()
#define LIS2DH12_INT1_GPIO_CLK_DISABLE()         __GPIOA_CLK_DISABLE()
#define LIS2DH12_INT1_PIN                        GPIO_PIN_3

#define LIS2DH12_INT1_EXTI_IRQn                  EXTI2_3_IRQn

#define LIS2DH12_INT2_GPIO_PORT                  GPIOA
#define LIS2DH12_INT2_GPIO_CLK_ENABLE()         __GPIOA_CLK_ENABLE()
#define LIS2DH12_INT2_GPIO_CLK_DISABLE()        __GPIOA_CLK_DISABLE()
#define LIS2DH12_INT2_PIN                       GPIO_PIN_2

#define LIS2DH12_INT2_EXTI_IRQn                 EXTI2_3_IRQn

#define SHT3X_DIS_ALERT_INT_GPIO_PORT           GPIOA
#define SHT3X_DIS_ALERT_INT_GPIO_CLK_ENABLE()   __GPIOA_CLK_ENABLE()
#define SHT3X_DIS_ALERT_INT_GPIO_CLK_DISABLE()  __GPIOA_CLK_DISABLE()
#define SHT3X_DIS_ALERT_INT_PIN                 GPIO_PIN_1

#define SHT3X_DIS_ALERT_INT_EXTI_IRQn                 EXTI0_1_IRQn
/**
  * @}
  */
/*Pubilc function prototypes****************************************************************************************/
/*lis2dh12*/
uint8_t LIS2DH12_IO_Init(void);
DrvStatusTypeDef LIS2DH12_Sensor_IO_ITConfig( void );
uint8_t LIS2DH12_IO_Write( uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
        uint16_t NumByteToWrite );
uint8_t LIS2DH12_IO_Read( uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
        uint16_t NumByteToRead, uint8_t DMA_flag );
        
/*sht3x_dis*/
uint8_t SHT3X_DIS_IO_Init(void);
DrvStatusTypeDef SHT3X_DIS_Sensor_IO_ITConfig( void );
uint8_t SHT3X_DIS_IO_Write( uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
        uint16_t NumByteToWrite );
uint8_t SHT3X_DIS_IO_Read( uint8_t* pBuffer, uint8_t DeviceAddr, uint8_t RegisterAddr,
        uint16_t NumByteToRead, uint8_t DMA_flag );
/**
  * @}
  */

/**
  * @}
  */

/**
  * @}
  */

#ifdef __cplusplus
}
#endif

#endif /* __X_NUCLEO_IKS01A1_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
